Inline expansion, also called “inlining”, is a manual or automated (e.g., by a compiler or linker) modification of software code that replaces a routine call with the body of the called routine. Some languages, such as C and C++, support an “inline” keyword in routine definitions, allowing developers to suggest to a compiler that the compiler should try to inline the routine. Compilers use developer suggestions and other criteria to decide which routine calls should be inlined. Linkers may perform inlining, e.g., with routines whose source is not available and with library routines. Run-time systems may also perform inlining.
An inlining optimization may improve a program's time and space usage at runtime, but may also increase the size of the program's binary file. Inlining tends to improve code execution speed, but inlining may also decrease performance. For example, inserting multiple copies of a routine may increase code size enough that the code no longer fits in the cache, resulting in more cache misses. In an embedded system, smaller code size may be more important than faster code execution, making inlining unattractive. In some systems, added variables from inlining may increase processor register usage enough to cause extra RAM accesses, thereby decreasing execution speed. Some routines cannot be inlined, such as some recursive routines.